<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="com.farm.web.constant.FarmConstant"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>

<style>
#chooseTreeBoxContentId span {
	cursor: pointer;
}

#chooseTreeBoxContentId span:hover {
	color: #ffffff;
}
</style>



<div id="dirFilesTreeWinId" class="modal fade " tabindex="-1"
	role="dialog" aria-labelledby="mySmallModalLabel">
	<div class="modal-dialog modal-sm" role="document">
		<div class="modal-content" style="background-color: #666666">
			<div style="margin: 20px;" id="chooseTreeBoxId"
				class="chooseTreeBoxClass">
				<div class="wcp-tree-node" data-id="NONE"
					style="margin-left: 0px; overflow: auto; padding-bottom: 20px;">
					<div class="wcp-tree-lable">
						<i class="glyphicon glyphicon-inbox tag"></i><span>${template.name }</span>
					</div>
					<div class="wcp-tree-subnode" id="chooseTreeBoxContentId"
						style="margin-left: -20px;"></div>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	//刷新目录树
	function initChooseTree() {
		$('#chooseTreeBoxContentId').html('');
		$.post('temveiw/loadfiles.do', {
			'templateid' : "${template.id}"
		}, function(flag) {
			if (flag.STATE == 0) {
				$(flag.dirs).each(function(i, node) {
					showDirByChooseTree(node.parentid, {
						'id' : node.id,
						'name' : node.name,
						'sort' : node.sort,
						'note' : node.pcontent
					}, false);
				});
			} else {
				alert(flag.MESSAGE);
			}
		}, 'json');
	}

	function showDirByChooseTree(nodeId, node, isfile) {
		var elements = $('[data-id="' + nodeId + '"]', '#chooseTreeBoxId');
		var dH = "";
		dH = dH
				+ '<div class="wcp-tree-node dir"  data-name="'+node.name+'" data-id="'+node.id+'" data-type="dir" data-fold="true">';
		dH = dH + '<div class="wcp-tree-lable" title="'+node.note+'">';
		dH = dH + '<i class="f-fold none tag"></i> ';
		dH = dH
				+ '<i class="f-model glyphicon glyphicon-folder-close tag"></i>';
		dH = dH + '<span onclick="chooseDirNodeBackFunction(\'' + node.id
				+ '\')">' + node.name + '</span>';
		dH = dH + '</div>';
		dH = dH + '<div class="wcp-tree-subnode"></div>';
		dH = dH + "</div>";
		$(elements).children('.wcp-tree-subnode').append(dH);
	}

	function chooseDirNodeBackFunction(dirid) {
		alert("用户选择目录后的回调方法");
	}
</script>